package com.solomiao.demo.multi.thread.demo9;

import com.solomiao.demo.multi.thread.demo8.CallableDemo8;

import java.util.concurrent.*;

/**
 * @desc 使用CompletableFuture提交Supplier任务，阻塞获取返回值
 * */
public class MainDemo9 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Long> future = CompletableFuture.supplyAsync(new SupplierDemo9(), Executors.newSingleThreadExecutor());

        System.out.println("主线程做其他事情...");
        Long result = future.get(); // 阻塞获取结果
        System.out.println("异步任务返回值：" + result);
    }


}
